<template>
  <div class="container">
    <div class="box">
      <div class="shade" :class="{ moved: isMoved }">
        <button @click="change">点击移动</button>
      </div>
      <div class="hidden" :class="{ moved: isMoved }"></div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'Login1View',
  data() {
    return {
      isMoved: false,
    }
  },
  methods: {
    change() {
      this.isMoved = !this.isMoved
    },
  },
}
</script>

<style lang="scss" scoped>
.box {
  width: 1000px;
  height: 500px;
  position: relative;
  border: 1px solid #ccc;
  margin: 100px auto;
  background: url('https://www.euweb.cn/wp-content/uploads/2016/12/302636-106.jpg');
  background-size: cover; /* 使图片完整展示 */
  background-position: center; /* 确保图片居中 */
  background-attachment: scroll; /* 默认的滚动行为，图片随内容滚动 */
  border-radius: 20px;
}

.shade {
  width: 500px;
  height: 500px;
  position: absolute;
  top: 0;
  background-color: transparent;
  z-index: 2;
  transition: transform 0.5s ease;
}

.hidden {
  width: 500px;
  height: 500px;
  position: absolute;
  top: 0;
  right: 0px;
  background: skyblue;
  z-index: 1;
  transition: transform 0.5s ease;
}

.shade.moved {
  transform: translateX(500px);
}

.hidden.moved {
  transform: translateX(-500px);
}
</style>
